package com.zeny.coding.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zeny.coding.util.DtoUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.xml.bind.ValidationException;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class SmsDto {
    private String id;

    private String mobile;

    private String code;

    private String use;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date at;

    private String status;

    public void isValidForSendCode() throws ValidationException {
        //检查手机号
        DtoUtil.valid(this.mobile, true, 11, 11);
        //检查用途 REGISTER("R", "注册"), FORGET("F", "忘记密码")',
        DtoUtil.valid(this.use, true, 1, 1);
    }

}